package com.shanghaionstar.discover.geofence.presenter;

import com.onstar.cn.framework.mvp.base.IMVPScheduler;
import com.onstar.cn.framework.mvp.base.IMVPView;
import com.onstar.cn.framework.mvp.base.core.BaseActivity;
import com.onstar.cn.framework.mvp.base.core.BasePresenter;
import com.onstar.cn.mag.GeofenceInfoEntity;
import com.shanghaionstar.R;
import com.shanghaionstar.discover.geofence.iview.IGeofencePreView;

/**
 * Created by 7828wc on 16/7/21.
 */
public class GeofencePreviewPresenter extends BasePresenter<Object> {
    private BaseActivity mContext;

    public GeofencePreviewPresenter(IMVPScheduler mvpScheduler) {
        super(mvpScheduler);
    }

    @Override
    public void setView(IMVPView<Object> view) {
        super.setView(view);
        this.view = view;
        mContext = (BaseActivity) view.onActivity();
    }


    public String getRangeUnit(GeofenceInfoEntity entity){
        return entity.getRangeUnit().equalsIgnoreCase("KM")?mContext.getString(R.string.geofence_range_unit_km):mContext.getString(R.string.geofence_range_unit_m);
    }

    public void getIntent(){
        GeofenceInfoEntity detailGeoFenceInfo = (GeofenceInfoEntity) mContext.getIntent().getSerializableExtra(GeofenceInfoEntity.GEOFENCE_TAG);
        if(view instanceof  IGeofencePreView){
            ((IGeofencePreView) view).displayView(detailGeoFenceInfo);
        }
//        view.displayView(detailGeoFenceInfo);
//        if (detailGeoFenceInfo != null) {
//            mapHandler = new MapHandler(this, mapview.getMap());
//            mapHandler.setGeoFenceCircle(detailGeoFenceInfo);
//
//            tv_geofence_name.setText(detailGeoFenceInfo.getName());
//            tv_geofence_center.setText(detailGeoFenceInfo.getCenterPoiAddress());
//            tv_geofence_mobile.setText(detailGeoFenceInfo.getMobile());
//            tv_geofence_range.setText(detailGeoFenceInfo.getRange() + detailGeoFenceInfo.getRangeUnit());
//
//            bottom_detail_view.setVisibility(View.VISIBLE);
//        } else {
//            bottom_detail_view.setVisibility(View.GONE);
//        }
    }
}
